<?php

//error_reporting(!E_WARNING);
require_once 'ArrayBuild.php';




$oferty = new ArrayBuild(
'http://www.jobvector.pl/',
 'http://www.jobvector.pl/wyszukiwanie-ofert.html?keywords=&type=or&location_tree_list=&finish_button=Szukaj+og%C5%82osze%C5%84',
 '//*[@id="eintrag"]/div[2]/div[4]/center/table/tbody/tr/td/div/div[2]/a/@href',
 '//h3/a/@href',
 '//*[@id="listView"]/div/div/div[3]/div[2]',
 '//*[@id="listView"]/div/div/h3/a',
 '//*[@id="listView"]/div/div/div[3]/div[1]',
 '//*[@id="listView"]/div/div/div[3]/div[3]'
        );


$oferty->getElements();
$oferty->generateXML();




/**
  /**
  //------------------------------------------------------------------------------

  $linkList = $XPath->query('//a[@class="offerLink"]/@href');

  foreach($linkList as $hrefElement)
  {
  $href[] = $site.$hrefElement->value;
  }
  //------------------------------------------------------------------------------

  $empList = $XPath->query('//a[@class="empLink"]');

  foreach($empList as $emp)
  {
  $employees[] = $emp->nodeValue;
  }
  //------------------------------------------------------------------------------

  $jobList = $XPath->query('//a[@class="offerLink"]');

  foreach($jobList as $job)
  {
  $jobs[] = $job->firstChild->nodeValue;
  }
  //------------------------------------------------------------------------------

  $datesList = $XPath->query('//p[@class="oT"]');

  foreach($datesList as $date)
  {
  $dates[] = $date->nodeValue;
  }
  //------------------------------------------------------------------------------

  $locationsList = $XPath->query('//p[@class="oP"]');
  foreach($locationsList as $elem)
  {
  $locations[] = $elem->nodeValue;
  }
  //------------------------------------------------------------------------------

  foreach($href as $h)
  {

  $localOffer = new DOMDocument();
  $localOffer->loadHTML(file_get_contents($h));
  $offerPath = new DOMXPath($localOffer);
  $res =  $offerPath->query('//*[@id="offCont"]');
  foreach ($res as $r)
  {
  $jobOffer[] = $r->nodeValue;
  }

  }
 * */
/**
  $XMLDocument = new DOMDocument('1.0','utf-8');
  $XMLDocument->formatOutput = true;

  $Oferty = $XMLDocument->appendChild($XMLDocument->createElement('Oferty'));

  $licznik = count($jobs);
  for($i = 0; $i<$licznik; ++$i)
  {
  $Oferta = $Oferty->appendChild($XMLDocument->createElement('Oferta'));
  $Oferta->appendChild($XMLDocument->createElement('Praca', html_entity_decode($jobs[$i])));
  $Oferta->appendChild($XMLDocument->createElement('Pracodawca', html_entity_decode($employees[$i] )));
  $Oferta->appendChild($XMLDocument->createElement('Lokalizacja', html_entity_decode($locations[$i] )));
  $Oferta->appendChild($XMLDocument->createElement('Data', html_entity_decode($dates[$i] )));
  $Oferta->appendChild($XMLDocument->createElement('Link', html_entity_decode($href[$i] )));
  $Oferta->appendChild($XMLDocument->createElement('Oferta', html_entity_decode($jobOffer[$i])));
  }
  file_put_contents('Import.xml', $XMLDocument->saveXML());


 * */
?>